package fr.enseirb.mycub.activity.component.slidingmenu;

import android.util.Log;
import fr.enseirb.mycub.PrefManager;
import fr.enseirb.mycub.utils.Constants;

public abstract class SlidingMenuItem {
	public final int id;
	public final String name;
	public final int iconRessource;
	public boolean checked = false;
	public final boolean isLayer;
	public SlidingMenuItem(int id, String name, int iconRessource, boolean isLayer, boolean checked) {
		this.checked = checked;
		this.id = id;
		this.name = name; 
		this.iconRessource = iconRessource;
		this.isLayer = isLayer;
	}
	
	public void onClick(boolean restore){
		if(!restore && isLayer){
			checked = !checked;
			PrefManager.edit.putBoolean(Constants.PREF_SLIDING_MENU_ITEM+id, checked);
			PrefManager.edit.commit();
			Log.i("SlidingMenuItem", name + " SAVED TO "+checked);
		}
		else checked = true;
		onClickImpl();
	}
	
	protected abstract void onClickImpl();
	
}
